package com.choosefine.base.common.beetl.function

import com.google.common.base.Ascii
import com.google.common.base.Joiner

/**
 * Created by 邱鹏 on 2017/8/24.
 * 功能作用：给beetl，beetlsql提供函数支持
 */
open class KotlinFun {
    /**
     * 首字母小写
     */
    fun lowerFirst(word: String): String {
        var length = word.length
        if (length == 0) {
            return word
        }
        return StringBuilder(length)
                .append(Ascii.toLowerCase(word.toCharArray()[0]))
                .append(word.substring(1))
                .toString()
    }

    /**
     *将java 的package转化为url
     */
    fun packageToUrl(word: String): String {
        var result = ""
        var strList: List<String> = word.split(".").filter { !"com".equals(it) }//将不等于com的返回
        result = "/" + Joiner.on("/").join(strList)
        return result
    }

    /**
     *允许使用静态方法进行调用
     */
    companion object {
        val kotlin = KotlinFun()
        @JvmStatic
        fun instance() = kotlin

    }
}